﻿//
// *************************************************************************************
// WP-Framework
// 
// Developed by
// Lukas Kretschmar (lkretschmar.dev@bluewin.ch)
//
// Switzerland, Copyright (c) 2013 lkretschmar
// This content is released under the MIT License (http://opensource.org/licenses/MIT).
//     
// *************************************************************************************
//
//



using System.Linq;
using System.Collections.Generic;

namespace KretschIT.WP_Fx.EasyMoq.Generator.Core
{
    internal abstract class StringBuilder : IStringBuilder
    {
        private const string Separator = ", ";

        private List<string> arguments = new List<string>();

        protected void Add(string argument)
        {
            arguments.Add(argument);
        }

        public string String
        {
            get 
            {
                var arguments = this.CreateArgumentString();
                return this.PostProcess(arguments);
            }
        }

        private string CreateArgumentString()
        {
            if (this.arguments.Any())
            {
                var firstArgument = this.arguments.First();
                return this.arguments.Skip(1).Aggregate(firstArgument, (args, arg) => args + Separator + arg);
            }
            return string.Empty;
        }

        protected virtual string PostProcess(string argumentString)
        {
            return argumentString;
        }
    }
}
